import request from '../utils/request'
import qs from 'qs'
import { AxiosResponse } from 'axios'

interface User {
  phone:string
  password:string
}

interface Login {
  content: string
  message: string
  state: number
  success:boolean
}
interface UserInfoContent {
  isUpdatedPassword:boolean
  userName:string
  portrait:string
}

interface UserInfo{
  state:number
  message:string
  content:UserInfoContent
  success:boolean
}

// AxiosPromise<AxiosResponse>
export const userLogin = (data: User):Promise<AxiosResponse<Login>> => {
  return request({
    method: 'POST',
    url: '/front/user/login',
    // headers: { 'content-type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(data)
  })
}

export const getUserInfo = ():Promise<AxiosResponse<UserInfo>> => {
  return request({
    method: 'GET',
    url: '/front/user/getInfo'
    // headers: {
    //   Authorization: store.state.user.access_token
    // }
  })
}

export const getUserPages = (data:any):Promise<AxiosResponse> => {
  return request({
    method: 'POST',
    url: '/boss/user/getUserPages',
    data
  })
}
